package cn.xm.lingshi.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.xm.lingshi.pojo.DingDan;
import cn.xm.lingshi.pojo.GouWuChe;
import cn.xm.lingshi.service.OrderService;
import cn.xm.lingshi.service.impl.OrderServiceImpl;

public class addOrderServlet extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	
	public void destroy() {
		super.destroy(); 
		
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		request.setCharacterEncoding("UTF-8");
		OrderService order=new OrderServiceImpl();
		GouWuChe cart=(GouWuChe)request.getSession().getAttribute("cart");
		String address=(String)request.getSession().getAttribute("address");
		order.addOrder(cart, address);
		out.flush();
		out.close();
	}


	public void init() throws ServletException {
		
	}

}
